{
  "nbformat": 4,
  "nbformat_minor": 0,
  "metadata": {
    "colab": {
      "name": "TuriCreate-Early Stage DM Prediction.ipynb",
      "provenance": [],
      "collapsed_sections": []
    },
    "kernelspec": {
      "name": "python3",
      "display_name": "Python 3"
    },
    "language_info": {
      "name": "python"
    }
  },
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "qOPf50LzcPWW"
      },
      "source": [
        "### Binary Classification with TuriCreate \n",
        "+ TuriCreate\n",
        "  - made by Apple\n",
        "\n",
        "#### Task\n",
        "+ Predict Early stage diabetes risk \n",
        "+ https://archive.ics.uci.edu/ml/datasets/Early+stage+diabetes+risk+prediction+dataset.\n",
        "\n",
        "#### Installation\n",
        "+ pip install turicreate\n",
        "\n",
        "\n",
        "#### Features\n",
        "+ Easy-to-use: Focus on tasks instead of algorithms\n",
        "+ Visual: Built-in, streaming visualizations to explore your data\n",
        "+ Flexible: Supports text, images, audio, video and sensor data\n",
        "+ Fast and Scalable: Work with large datasets on a single machine\n",
        "+ Ready To Deploy: Export models to Core ML for use in iOS, macOS, watchOS, and tvOS apps"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "jbwUrKuZcC50"
      },
      "source": [
        "data_url = \"https://archive.ics.uci.edu/ml/machine-learning-databases/00529/diabetes_data_upload.csv\""
      ],
      "execution_count": 3,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "3kkM80jtdlDO",
        "outputId": "37c9de28-0555-42a5-d773-c506b4fb57a8"
      },
      "source": [
        "!pip install turicreate"
      ],
      "execution_count": 4,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "Collecting turicreate\n",
            "\u001b[?25l  Downloading https://files.pythonhosted.org/packages/25/9f/a76acc465d873d217f05eac4846bd73d640b9db6d6f4a3c29ad92650fbbe/turicreate-6.4.1-cp37-cp37m-manylinux1_x86_64.whl (92.0MB)\n",
            "\u001b[K     |████████████████████████████████| 92.0MB 61kB/s \n",
            "\u001b[?25hCollecting coremltools==3.3\n",
            "\u001b[?25l  Downloading https://files.pythonhosted.org/packages/1b/1d/b1a99beca7355b6a026ae61fd8d3d36136e5b36f13e92ec5f81aceffc7f1/coremltools-3.3-cp37-none-manylinux1_x86_64.whl (3.5MB)\n",
            "\u001b[K     |████████████████████████████████| 3.5MB 32.4MB/s \n",
            "\u001b[?25hRequirement already satisfied: requests>=2.9.1 in /usr/local/lib/python3.7/dist-packages (from turicreate) (2.23.0)\n",
            "Collecting numba<0.51.0\n",
            "\u001b[?25l  Downloading https://files.pythonhosted.org/packages/04/be/8c88cee3366de2a3a23a9ff1a8be34e79ad1eb1ceb0d0e33aca83655ac3c/numba-0.50.1-cp37-cp37m-manylinux2014_x86_64.whl (3.6MB)\n",
            "\u001b[K     |████████████████████████████████| 3.6MB 42.5MB/s \n",
            "\u001b[?25hRequirement already satisfied: pandas>=0.23.2 in /usr/local/lib/python3.7/dist-packages (from turicreate) (1.1.5)\n",
            "Requirement already satisfied: six>=1.10.0 in /usr/local/lib/python3.7/dist-packages (from turicreate) (1.15.0)\n",
            "Requirement already satisfied: decorator>=4.0.9 in /usr/local/lib/python3.7/dist-packages (from turicreate) (4.4.2)\n",
            "Collecting resampy==0.2.1\n",
            "\u001b[?25l  Downloading https://files.pythonhosted.org/packages/14/b6/66a06d85474190b50aee1a6c09cdc95bb405ac47338b27e9b21409da1760/resampy-0.2.1.tar.gz (322kB)\n",
            "\u001b[K     |████████████████████████████████| 327kB 43.0MB/s \n",
            "\u001b[?25hRequirement already satisfied: pillow>=5.2.0 in /usr/local/lib/python3.7/dist-packages (from turicreate) (7.1.2)\n",
            "Requirement already satisfied: numpy in /usr/local/lib/python3.7/dist-packages (from turicreate) (1.19.5)\n",
            "Collecting tensorflow<2.1.0,>=2.0.0\n",
            "\u001b[?25l  Downloading https://files.pythonhosted.org/packages/3c/b3/3eeae9bc44039ceadceac0c7ba1cc8b1482b172810b3d7624a1cad251437/tensorflow-2.0.4-cp37-cp37m-manylinux2010_x86_64.whl (86.4MB)\n",
            "\u001b[K     |████████████████████████████████| 86.4MB 47kB/s \n",
            "\u001b[?25hCollecting prettytable==0.7.2\n",
            "  Downloading https://files.pythonhosted.org/packages/ef/30/4b0746848746ed5941f052479e7c23d2b56d174b82f4fd34a25e389831f5/prettytable-0.7.2.tar.bz2\n",
            "Requirement already satisfied: scipy>=1.1.0 in /usr/local/lib/python3.7/dist-packages (from turicreate) (1.4.1)\n",
            "Requirement already satisfied: protobuf>=3.1.0 in /usr/local/lib/python3.7/dist-packages (from coremltools==3.3->turicreate) (3.12.4)\n",
            "Requirement already satisfied: chardet<4,>=3.0.2 in /usr/local/lib/python3.7/dist-packages (from requests>=2.9.1->turicreate) (3.0.4)\n",
            "Requirement already satisfied: idna<3,>=2.5 in /usr/local/lib/python3.7/dist-packages (from requests>=2.9.1->turicreate) (2.10)\n",
            "Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.7/dist-packages (from requests>=2.9.1->turicreate) (2020.12.5)\n",
            "Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /usr/local/lib/python3.7/dist-packages (from requests>=2.9.1->turicreate) (1.24.3)\n",
            "Requirement already satisfied: setuptools in /usr/local/lib/python3.7/dist-packages (from numba<0.51.0->turicreate) (56.1.0)\n",
            "Collecting llvmlite<0.34,>=0.33.0.dev0\n",
            "\u001b[?25l  Downloading https://files.pythonhosted.org/packages/0a/28/0a35b3c2685bf2ea327cef5577bdf91f387f0f4594417a2a05a1d42fb7c2/llvmlite-0.33.0-cp37-cp37m-manylinux1_x86_64.whl (18.3MB)\n",
            "\u001b[K     |████████████████████████████████| 18.3MB 255kB/s \n",
            "\u001b[?25hRequirement already satisfied: pytz>=2017.2 in /usr/local/lib/python3.7/dist-packages (from pandas>=0.23.2->turicreate) (2018.9)\n",
            "Requirement already satisfied: python-dateutil>=2.7.3 in /usr/local/lib/python3.7/dist-packages (from pandas>=0.23.2->turicreate) (2.8.1)\n",
            "Requirement already satisfied: keras-preprocessing>=1.0.5 in /usr/local/lib/python3.7/dist-packages (from tensorflow<2.1.0,>=2.0.0->turicreate) (1.1.2)\n",
            "Collecting h5py<=2.10.0\n",
            "\u001b[?25l  Downloading https://files.pythonhosted.org/packages/3f/c0/abde58b837e066bca19a3f7332d9d0493521d7dd6b48248451a9e3fe2214/h5py-2.10.0-cp37-cp37m-manylinux1_x86_64.whl (2.9MB)\n",
            "\u001b[K     |████████████████████████████████| 2.9MB 28.4MB/s \n",
            "\u001b[?25hRequirement already satisfied: google-pasta>=0.1.6 in /usr/local/lib/python3.7/dist-packages (from tensorflow<2.1.0,>=2.0.0->turicreate) (0.2.0)\n",
            "Collecting keras-applications>=1.0.8\n",
            "\u001b[?25l  Downloading https://files.pythonhosted.org/packages/71/e3/19762fdfc62877ae9102edf6342d71b28fbfd9dea3d2f96a882ce099b03f/Keras_Applications-1.0.8-py3-none-any.whl (50kB)\n",
            "\u001b[K     |████████████████████████████████| 51kB 7.1MB/s \n",
            "\u001b[?25hRequirement already satisfied: wrapt>=1.11.1 in /usr/local/lib/python3.7/dist-packages (from tensorflow<2.1.0,>=2.0.0->turicreate) (1.12.1)\n",
            "Requirement already satisfied: grpcio>=1.8.6 in /usr/local/lib/python3.7/dist-packages (from tensorflow<2.1.0,>=2.0.0->turicreate) (1.34.1)\n",
            "Requirement already satisfied: wheel>=0.26; python_version >= \"3\" in /usr/local/lib/python3.7/dist-packages (from tensorflow<2.1.0,>=2.0.0->turicreate) (0.36.2)\n",
            "Collecting tensorflow-estimator<2.1.0,>=2.0.0\n",
            "\u001b[?25l  Downloading https://files.pythonhosted.org/packages/fc/08/8b927337b7019c374719145d1dceba21a8bb909b93b1ad6f8fb7d22c1ca1/tensorflow_estimator-2.0.1-py2.py3-none-any.whl (449kB)\n",
            "\u001b[K     |████████████████████████████████| 450kB 44.9MB/s \n",
            "\u001b[?25hRequirement already satisfied: absl-py>=0.7.0 in /usr/local/lib/python3.7/dist-packages (from tensorflow<2.1.0,>=2.0.0->turicreate) (0.12.0)\n",
            "Requirement already satisfied: astor>=0.6.0 in /usr/local/lib/python3.7/dist-packages (from tensorflow<2.1.0,>=2.0.0->turicreate) (0.8.1)\n",
            "Requirement already satisfied: opt-einsum>=2.3.2 in /usr/local/lib/python3.7/dist-packages (from tensorflow<2.1.0,>=2.0.0->turicreate) (3.3.0)\n",
            "Requirement already satisfied: termcolor>=1.1.0 in /usr/local/lib/python3.7/dist-packages (from tensorflow<2.1.0,>=2.0.0->turicreate) (1.1.0)\n",
            "Collecting tensorboard<2.1.0,>=2.0.0\n",
            "\u001b[?25l  Downloading https://files.pythonhosted.org/packages/76/54/99b9d5d52d5cb732f099baaaf7740403e83fe6b0cedde940fabd2b13d75a/tensorboard-2.0.2-py3-none-any.whl (3.8MB)\n",
            "\u001b[K     |████████████████████████████████| 3.8MB 46.2MB/s \n",
            "\u001b[?25hCollecting gast==0.2.2\n",
            "  Downloading https://files.pythonhosted.org/packages/4e/35/11749bf99b2d4e3cceb4d55ca22590b0d7c2c62b9de38ac4a4a7f4687421/gast-0.2.2.tar.gz\n",
            "Requirement already satisfied: google-auth-oauthlib<0.5,>=0.4.1 in /usr/local/lib/python3.7/dist-packages (from tensorboard<2.1.0,>=2.0.0->tensorflow<2.1.0,>=2.0.0->turicreate) (0.4.4)\n",
            "Requirement already satisfied: google-auth<2,>=1.6.3 in /usr/local/lib/python3.7/dist-packages (from tensorboard<2.1.0,>=2.0.0->tensorflow<2.1.0,>=2.0.0->turicreate) (1.30.0)\n",
            "Requirement already satisfied: werkzeug>=0.11.15 in /usr/local/lib/python3.7/dist-packages (from tensorboard<2.1.0,>=2.0.0->tensorflow<2.1.0,>=2.0.0->turicreate) (1.0.1)\n",
            "Requirement already satisfied: markdown>=2.6.8 in /usr/local/lib/python3.7/dist-packages (from tensorboard<2.1.0,>=2.0.0->tensorflow<2.1.0,>=2.0.0->turicreate) (3.3.4)\n",
            "Requirement already satisfied: requests-oauthlib>=0.7.0 in /usr/local/lib/python3.7/dist-packages (from google-auth-oauthlib<0.5,>=0.4.1->tensorboard<2.1.0,>=2.0.0->tensorflow<2.1.0,>=2.0.0->turicreate) (1.3.0)\n",
            "Requirement already satisfied: cachetools<5.0,>=2.0.0 in /usr/local/lib/python3.7/dist-packages (from google-auth<2,>=1.6.3->tensorboard<2.1.0,>=2.0.0->tensorflow<2.1.0,>=2.0.0->turicreate) (4.2.2)\n",
            "Requirement already satisfied: pyasn1-modules>=0.2.1 in /usr/local/lib/python3.7/dist-packages (from google-auth<2,>=1.6.3->tensorboard<2.1.0,>=2.0.0->tensorflow<2.1.0,>=2.0.0->turicreate) (0.2.8)\n",
            "Requirement already satisfied: rsa<5,>=3.1.4; python_version >= \"3.6\" in /usr/local/lib/python3.7/dist-packages (from google-auth<2,>=1.6.3->tensorboard<2.1.0,>=2.0.0->tensorflow<2.1.0,>=2.0.0->turicreate) (4.7.2)\n",
            "Requirement already satisfied: importlib-metadata; python_version < \"3.8\" in /usr/local/lib/python3.7/dist-packages (from markdown>=2.6.8->tensorboard<2.1.0,>=2.0.0->tensorflow<2.1.0,>=2.0.0->turicreate) (4.0.1)\n",
            "Requirement already satisfied: oauthlib>=3.0.0 in /usr/local/lib/python3.7/dist-packages (from requests-oauthlib>=0.7.0->google-auth-oauthlib<0.5,>=0.4.1->tensorboard<2.1.0,>=2.0.0->tensorflow<2.1.0,>=2.0.0->turicreate) (3.1.0)\n",
            "Requirement already satisfied: pyasn1<0.5.0,>=0.4.6 in /usr/local/lib/python3.7/dist-packages (from pyasn1-modules>=0.2.1->google-auth<2,>=1.6.3->tensorboard<2.1.0,>=2.0.0->tensorflow<2.1.0,>=2.0.0->turicreate) (0.4.8)\n",
            "Requirement already satisfied: typing-extensions>=3.6.4; python_version < \"3.8\" in /usr/local/lib/python3.7/dist-packages (from importlib-metadata; python_version < \"3.8\"->markdown>=2.6.8->tensorboard<2.1.0,>=2.0.0->tensorflow<2.1.0,>=2.0.0->turicreate) (3.7.4.3)\n",
            "Requirement already satisfied: zipp>=0.5 in /usr/local/lib/python3.7/dist-packages (from importlib-metadata; python_version < \"3.8\"->markdown>=2.6.8->tensorboard<2.1.0,>=2.0.0->tensorflow<2.1.0,>=2.0.0->turicreate) (3.4.1)\n",
            "Building wheels for collected packages: resampy, prettytable, gast\n",
            "  Building wheel for resampy (setup.py) ... \u001b[?25l\u001b[?25hdone\n",
            "  Created wheel for resampy: filename=resampy-0.2.1-cp37-none-any.whl size=320845 sha256=5b07c73298352b43b23f9470a493208db4537c297ea21b2dd118ec373f30f321\n",
            "  Stored in directory: /root/.cache/pip/wheels/ff/4f/ed/2e6c676c23efe5394bb40ade50662e90eb46e29b48324c5f9b\n",
            "  Building wheel for prettytable (setup.py) ... \u001b[?25l\u001b[?25hdone\n",
            "  Created wheel for prettytable: filename=prettytable-0.7.2-cp37-none-any.whl size=13700 sha256=03a8f9f0825d6c26e919a8fe0248aff7eac260da67e3f3dfe61a090754d69091\n",
            "  Stored in directory: /root/.cache/pip/wheels/80/34/1c/3967380d9676d162cb59513bd9dc862d0584e045a162095606\n",
            "  Building wheel for gast (setup.py) ... \u001b[?25l\u001b[?25hdone\n",
            "  Created wheel for gast: filename=gast-0.2.2-cp37-none-any.whl size=7540 sha256=47daaf2647830d9b1e838ad8f44fb2f042f4c75315d06715c914233202cf9c39\n",
            "  Stored in directory: /root/.cache/pip/wheels/5c/2e/7e/a1d4d4fcebe6c381f378ce7743a3ced3699feb89bcfbdadadd\n",
            "Successfully built resampy prettytable gast\n",
            "\u001b[31mERROR: tensorflow 2.0.4 has requirement numpy<1.19.0,>=1.16.0, but you'll have numpy 1.19.5 which is incompatible.\u001b[0m\n",
            "\u001b[31mERROR: tensorflow-probability 0.12.1 has requirement gast>=0.3.2, but you'll have gast 0.2.2 which is incompatible.\u001b[0m\n",
            "\u001b[31mERROR: librosa 0.8.0 has requirement resampy>=0.2.2, but you'll have resampy 0.2.1 which is incompatible.\u001b[0m\n",
            "Installing collected packages: coremltools, llvmlite, numba, resampy, h5py, keras-applications, tensorflow-estimator, tensorboard, gast, tensorflow, prettytable, turicreate\n",
            "  Found existing installation: llvmlite 0.34.0\n",
            "    Uninstalling llvmlite-0.34.0:\n",
            "      Successfully uninstalled llvmlite-0.34.0\n",
            "  Found existing installation: numba 0.51.2\n",
            "    Uninstalling numba-0.51.2:\n",
            "      Successfully uninstalled numba-0.51.2\n",
            "  Found existing installation: resampy 0.2.2\n",
            "    Uninstalling resampy-0.2.2:\n",
            "      Successfully uninstalled resampy-0.2.2\n",
            "  Found existing installation: h5py 3.1.0\n",
            "    Uninstalling h5py-3.1.0:\n",
            "      Successfully uninstalled h5py-3.1.0\n",
            "  Found existing installation: tensorflow-estimator 2.5.0\n",
            "    Uninstalling tensorflow-estimator-2.5.0:\n",
            "      Successfully uninstalled tensorflow-estimator-2.5.0\n",
            "  Found existing installation: tensorboard 2.5.0\n",
            "    Uninstalling tensorboard-2.5.0:\n",
            "      Successfully uninstalled tensorboard-2.5.0\n",
            "  Found existing installation: gast 0.4.0\n",
            "    Uninstalling gast-0.4.0:\n",
            "      Successfully uninstalled gast-0.4.0\n",
            "  Found existing installation: tensorflow 2.5.0\n",
            "    Uninstalling tensorflow-2.5.0:\n",
            "      Successfully uninstalled tensorflow-2.5.0\n",
            "  Found existing installation: prettytable 2.1.0\n",
            "    Uninstalling prettytable-2.1.0:\n",
            "      Successfully uninstalled prettytable-2.1.0\n",
            "Successfully installed coremltools-3.3 gast-0.2.2 h5py-2.10.0 keras-applications-1.0.8 llvmlite-0.33.0 numba-0.50.1 prettytable-0.7.2 resampy-0.2.1 tensorboard-2.0.2 tensorflow-2.0.4 tensorflow-estimator-2.0.1 turicreate-6.4.1\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "CmOSgh7Vdfoa"
      },
      "source": [
        "# Load Pkgs\n",
        "import turicreate as tc"
      ],
      "execution_count": 5,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 251
        },
        "id": "Gg_osx8TdihD",
        "outputId": "9c8cefb7-d684-4d38-9296-0c233571c6bb"
      },
      "source": [
        "# Load Dataset\n",
        "df = tc.SFrame(data_url)"
      ],
      "execution_count": 6,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "<pre>Downloading https://archive.ics.uci.edu/ml/machine-learning-databases/00529/diabetes_data_upload.csv to /var/tmp/turicreate-root/59/2862b7a9-30ed-4b77-b817-7535c7012ac0.csv</pre>"
            ],
            "text/plain": [
              "Downloading https://archive.ics.uci.edu/ml/machine-learning-databases/00529/diabetes_data_upload.csv to /var/tmp/turicreate-root/59/2862b7a9-30ed-4b77-b817-7535c7012ac0.csv"
            ]
          },
          "metadata": {
            "tags": []
          }
        },
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "<pre>Finished parsing file https://archive.ics.uci.edu/ml/machine-learning-databases/00529/diabetes_data_upload.csv</pre>"
            ],
            "text/plain": [
              "Finished parsing file https://archive.ics.uci.edu/ml/machine-learning-databases/00529/diabetes_data_upload.csv"
            ]
          },
          "metadata": {
            "tags": []
          }
        },
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "<pre>Parsing completed. Parsed 100 lines in 0.031653 secs.</pre>"
            ],
            "text/plain": [
              "Parsing completed. Parsed 100 lines in 0.031653 secs."
            ]
          },
          "metadata": {
            "tags": []
          }
        },
        {
          "output_type": "stream",
          "text": [
            "------------------------------------------------------\n",
            "Inferred types from first 100 line(s) of file as \n",
            "column_type_hints=[int,str,str,str,str,str,str,str,str,str,str,str,str,str,str,str,str]\n",
            "If parsing fails due to incorrect types, you can correct\n",
            "the inferred type list above and pass it to read_csv in\n",
            "the column_type_hints argument\n",
            "------------------------------------------------------\n"
          ],
          "name": "stdout"
        },
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "<pre>Finished parsing file https://archive.ics.uci.edu/ml/machine-learning-databases/00529/diabetes_data_upload.csv</pre>"
            ],
            "text/plain": [
              "Finished parsing file https://archive.ics.uci.edu/ml/machine-learning-databases/00529/diabetes_data_upload.csv"
            ]
          },
          "metadata": {
            "tags": []
          }
        },
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "<pre>Parsing completed. Parsed 520 lines in 0.014424 secs.</pre>"
            ],
            "text/plain": [
              "Parsing completed. Parsed 520 lines in 0.014424 secs."
            ]
          },
          "metadata": {
            "tags": []
          }
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 458
        },
        "id": "2GVTjLsUeY2n",
        "outputId": "af078fe0-b76a-452b-96fa-1d2ddd005f6e"
      },
      "source": [
        "# Preview Dataset\n",
        "df.head()"
      ],
      "execution_count": 7,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/html": [
              "<div style=\"max-height:1000px;max-width:1500px;overflow:auto;\"><table frame=\"box\" rules=\"cols\">\n",
              "    <tr>\n",
              "        <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">Age</th>\n",
              "        <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">Gender</th>\n",
              "        <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">Polyuria</th>\n",
              "        <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">Polydipsia</th>\n",
              "        <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">sudden weight loss</th>\n",
              "        <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">weakness</th>\n",
              "        <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">Polyphagia</th>\n",
              "        <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">Genital thrush</th>\n",
              "        <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">visual blurring</th>\n",
              "    </tr>\n",
              "    <tr>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">40</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">Male</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">No</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">Yes</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">No</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">Yes</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">No</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">No</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">No</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">58</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">Male</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">No</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">No</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">No</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">Yes</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">No</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">No</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">Yes</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">41</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">Male</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">Yes</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">No</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">No</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">Yes</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">Yes</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">No</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">No</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">45</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">Male</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">No</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">No</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">Yes</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">Yes</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">Yes</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">Yes</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">No</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">60</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">Male</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">Yes</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">Yes</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">Yes</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">Yes</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">Yes</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">No</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">Yes</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">55</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">Male</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">Yes</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">Yes</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">No</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">Yes</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">Yes</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">No</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">Yes</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">57</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">Male</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">Yes</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">Yes</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">No</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">Yes</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">Yes</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">Yes</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">No</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">66</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">Male</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">Yes</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">Yes</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">Yes</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">Yes</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">No</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">No</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">Yes</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">67</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">Male</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">Yes</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">Yes</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">No</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">Yes</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">Yes</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">Yes</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">No</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">70</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">Male</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">No</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">Yes</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">Yes</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">Yes</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">Yes</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">No</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">Yes</td>\n",
              "    </tr>\n",
              "</table>\n",
              "<table frame=\"box\" rules=\"cols\">\n",
              "    <tr>\n",
              "        <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">Itching</th>\n",
              "        <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">Irritability</th>\n",
              "        <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">delayed healing</th>\n",
              "        <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">partial paresis</th>\n",
              "        <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">muscle stiffness</th>\n",
              "        <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">Alopecia</th>\n",
              "        <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">Obesity</th>\n",
              "        <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">class</th>\n",
              "    </tr>\n",
              "    <tr>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">Yes</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">No</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">Yes</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">No</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">Yes</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">Yes</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">Yes</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">Positive</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">No</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">No</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">No</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">Yes</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">No</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">Yes</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">No</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">Positive</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">Yes</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">No</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">Yes</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">No</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">Yes</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">Yes</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">No</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">Positive</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">Yes</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">No</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">Yes</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">No</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">No</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">No</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">No</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">Positive</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">Yes</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">Yes</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">Yes</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">Yes</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">Yes</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">Yes</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">Yes</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">Positive</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">Yes</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">No</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">Yes</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">No</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">Yes</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">Yes</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">Yes</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">Positive</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">No</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">No</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">Yes</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">Yes</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">No</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">No</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">No</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">Positive</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">Yes</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">Yes</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">No</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">Yes</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">Yes</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">No</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">No</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">Positive</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">Yes</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">Yes</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">No</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">Yes</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">Yes</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">No</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">Yes</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">Positive</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">Yes</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">Yes</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">No</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">No</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">No</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">Yes</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">No</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">Positive</td>\n",
              "    </tr>\n",
              "</table>\n",
              "[10 rows x 17 columns]<br/>\n",
              "</div>"
            ],
            "text/plain": [
              "Columns:\n",
              "\tAge\tint\n",
              "\tGender\tstr\n",
              "\tPolyuria\tstr\n",
              "\tPolydipsia\tstr\n",
              "\tsudden weight loss\tstr\n",
              "\tweakness\tstr\n",
              "\tPolyphagia\tstr\n",
              "\tGenital thrush\tstr\n",
              "\tvisual blurring\tstr\n",
              "\tItching\tstr\n",
              "\tIrritability\tstr\n",
              "\tdelayed healing\tstr\n",
              "\tpartial paresis\tstr\n",
              "\tmuscle stiffness\tstr\n",
              "\tAlopecia\tstr\n",
              "\tObesity\tstr\n",
              "\tclass\tstr\n",
              "\n",
              "Rows: 10\n",
              "\n",
              "Data:\n",
              "+-----+--------+----------+------------+--------------------+----------+------------+\n",
              "| Age | Gender | Polyuria | Polydipsia | sudden weight loss | weakness | Polyphagia |\n",
              "+-----+--------+----------+------------+--------------------+----------+------------+\n",
              "|  40 |  Male  |    No    |    Yes     |         No         |   Yes    |     No     |\n",
              "|  58 |  Male  |    No    |     No     |         No         |   Yes    |     No     |\n",
              "|  41 |  Male  |   Yes    |     No     |         No         |   Yes    |    Yes     |\n",
              "|  45 |  Male  |    No    |     No     |        Yes         |   Yes    |    Yes     |\n",
              "|  60 |  Male  |   Yes    |    Yes     |        Yes         |   Yes    |    Yes     |\n",
              "|  55 |  Male  |   Yes    |    Yes     |         No         |   Yes    |    Yes     |\n",
              "|  57 |  Male  |   Yes    |    Yes     |         No         |   Yes    |    Yes     |\n",
              "|  66 |  Male  |   Yes    |    Yes     |        Yes         |   Yes    |     No     |\n",
              "|  67 |  Male  |   Yes    |    Yes     |         No         |   Yes    |    Yes     |\n",
              "|  70 |  Male  |    No    |    Yes     |        Yes         |   Yes    |    Yes     |\n",
              "+-----+--------+----------+------------+--------------------+----------+------------+\n",
              "+----------------+-----------------+---------+--------------+-----------------+\n",
              "| Genital thrush | visual blurring | Itching | Irritability | delayed healing |\n",
              "+----------------+-----------------+---------+--------------+-----------------+\n",
              "|       No       |        No       |   Yes   |      No      |       Yes       |\n",
              "|       No       |       Yes       |    No   |      No      |        No       |\n",
              "|       No       |        No       |   Yes   |      No      |       Yes       |\n",
              "|      Yes       |        No       |   Yes   |      No      |       Yes       |\n",
              "|       No       |       Yes       |   Yes   |     Yes      |       Yes       |\n",
              "|       No       |       Yes       |   Yes   |      No      |       Yes       |\n",
              "|      Yes       |        No       |    No   |      No      |       Yes       |\n",
              "|       No       |       Yes       |   Yes   |     Yes      |        No       |\n",
              "|      Yes       |        No       |   Yes   |     Yes      |        No       |\n",
              "|       No       |       Yes       |   Yes   |     Yes      |        No       |\n",
              "+----------------+-----------------+---------+--------------+-----------------+\n",
              "+-----------------+------------------+----------+---------+----------+\n",
              "| partial paresis | muscle stiffness | Alopecia | Obesity |  class   |\n",
              "+-----------------+------------------+----------+---------+----------+\n",
              "|        No       |       Yes        |   Yes    |   Yes   | Positive |\n",
              "|       Yes       |        No        |   Yes    |    No   | Positive |\n",
              "|        No       |       Yes        |   Yes    |    No   | Positive |\n",
              "|        No       |        No        |    No    |    No   | Positive |\n",
              "|       Yes       |       Yes        |   Yes    |   Yes   | Positive |\n",
              "|        No       |       Yes        |   Yes    |   Yes   | Positive |\n",
              "|       Yes       |        No        |    No    |    No   | Positive |\n",
              "|       Yes       |       Yes        |    No    |    No   | Positive |\n",
              "|       Yes       |       Yes        |    No    |   Yes   | Positive |\n",
              "|        No       |        No        |   Yes    |    No   | Positive |\n",
              "+-----------------+------------------+----------+---------+----------+\n",
              "[10 rows x 17 columns]"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 7
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "stvw0keGedEM",
        "outputId": "c13d74a4-4606-4652-ddd3-7c8feac39923"
      },
      "source": [
        "# Check Datatype\n",
        "df.dtype"
      ],
      "execution_count": 8,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "[int,\n",
              " str,\n",
              " str,\n",
              " str,\n",
              " str,\n",
              " str,\n",
              " str,\n",
              " str,\n",
              " str,\n",
              " str,\n",
              " str,\n",
              " str,\n",
              " str,\n",
              " str,\n",
              " str,\n",
              " str,\n",
              " str]"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 8
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 808
        },
        "id": "e625yrmXem6X",
        "outputId": "184a32f8-ad03-4624-9597-4f620d7b5a4f"
      },
      "source": [
        "# Plot the Value Count /Class Distribution\n",
        "df['class'].show()"
      ],
      "execution_count": 9,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "<pre>Materializing SArray</pre>"
            ],
            "text/plain": [
              "Materializing SArray"
            ]
          },
          "metadata": {
            "tags": []
          }
        },
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "<html>                 <body>                     <iframe style=\"border:0;margin:0\" width=\"920\" height=\"770\" srcdoc='<html lang=\"en\">                         <head>                             <script src=\"https://cdnjs.cloudflare.com/ajax/libs/vega/5.4.0/vega.js\"></script>                             <script src=\"https://cdnjs.cloudflare.com/ajax/libs/vega-embed/4.0.0/vega-embed.js\"></script>                             <script src=\"https://cdnjs.cloudflare.com/ajax/libs/vega-tooltip/0.5.1/vega-tooltip.min.js\"></script>                             <link rel=\"stylesheet\" type=\"text/css\" href=\"https://cdnjs.cloudflare.com/ajax/libs/vega-tooltip/0.5.1/vega-tooltip.min.css\">                             <style>                             .vega-actions > a{                                 color:white;                                 text-decoration: none;                                 font-family: \"Arial\";                                 cursor:pointer;                                 padding:5px;                                 background:#AAAAAA;                                 border-radius:4px;                                 padding-left:10px;                                 padding-right:10px;                                 margin-right:5px;                             }                             .vega-actions{                                 margin-top:20px;                                 text-align:center                             }                            .vega-actions > a{                                 background:#999999;                            }                             </style>                         </head>                         <body>                             <div id=\"vis\">                             </div>                             <script>                                 var vega_json = \"{\\\"$schema\\\": \\\"https://vega.github.io/schema/vega/v4.json\\\", \\\"autosize\\\": {\\\"type\\\": \\\"fit\\\", \\\"resize\\\": false, \\\"contains\\\": \\\"padding\\\"}, \\\"padding\\\": 8, \\\"metadata\\\": {\\\"bubbleOpts\\\": {\\\"showAllFields\\\": false, \\\"fields\\\": [{\\\"field\\\": \\\"count\\\"}, {\\\"field\\\": \\\"label\\\"}, {\\\"field\\\": \\\"percentage\\\"}]}}, \\\"width\\\": 720, \\\"height\\\": 550, \\\"title\\\": \\\"Distribution of Values [string]\\\", \\\"style\\\": \\\"cell\\\", \\\"data\\\": [{\\\"name\\\": \\\"pts_store_store\\\"}, {\\\"name\\\": \\\"source_2\\\", \\\"values\\\": [{\\\"label\\\": \\\"Positive\\\", \\\"label_idx\\\": 0, \\\"count\\\": 320, \\\"percentage\\\": \\\"61.5385%\\\"}, {\\\"label\\\": \\\"Negative\\\", \\\"label_idx\\\": 1, \\\"count\\\": 200, \\\"percentage\\\": \\\"38.4615%\\\"}]}, {\\\"name\\\": \\\"data_0\\\", \\\"source\\\": \\\"source_2\\\", \\\"transform\\\": [{\\\"type\\\": \\\"formula\\\", \\\"expr\\\": \\\"toNumber(datum[\\\\\\\"count\\\\\\\"])\\\", \\\"as\\\": \\\"count\\\"}, {\\\"type\\\": \\\"filter\\\", \\\"expr\\\": \\\"datum[\\\\\\\"count\\\\\\\"] !== null &amp;&amp; !isNaN(datum[\\\\\\\"count\\\\\\\"])\\\"}]}], \\\"signals\\\": [{\\\"name\\\": \\\"unit\\\", \\\"value\\\": {}, \\\"on\\\": [{\\\"events\\\": \\\"mousemove\\\", \\\"update\\\": \\\"isTuple(group()) ? group() : unit\\\"}]}, {\\\"name\\\": \\\"pts_store\\\", \\\"update\\\": \\\"data(\\\\\\\"pts_store_store\\\\\\\").length &amp;&amp; {count: data(\\\\\\\"pts_store_store\\\\\\\")[0].values[0]}\\\"}, {\\\"name\\\": \\\"pts_store_tuple\\\", \\\"value\\\": {}, \\\"on\\\": [{\\\"events\\\": [{\\\"source\\\": \\\"scope\\\", \\\"type\\\": \\\"click\\\"}], \\\"update\\\": \\\"datum &amp;&amp; item().mark.marktype !== &apos;group&apos; ? {unit: \\\\\\\"\\\\\\\", encodings: [\\\\\\\"x\\\\\\\"], fields: [\\\\\\\"count\\\\\\\"], values: [datum[\\\\\\\"count\\\\\\\"]]} : null\\\", \\\"force\\\": true}]}, {\\\"name\\\": \\\"pts_store_modify\\\", \\\"on\\\": [{\\\"events\\\": {\\\"signal\\\": \\\"pts_store_tuple\\\"}, \\\"update\\\": \\\"modify(\\\\\\\"pts_store_store\\\\\\\", pts_store_tuple, true)\\\"}]}], \\\"marks\\\": [{\\\"name\\\": \\\"marks\\\", \\\"type\\\": \\\"rect\\\", \\\"style\\\": [\\\"bar\\\"], \\\"from\\\": {\\\"data\\\": \\\"data_0\\\"}, \\\"encode\\\": {\\\"hover\\\": {\\\"fill\\\": {\\\"value\\\": \\\"#7EC2F3\\\"}}, \\\"update\\\": {\\\"x\\\": {\\\"scale\\\": \\\"x\\\", \\\"field\\\": \\\"count\\\"}, \\\"x2\\\": {\\\"scale\\\": \\\"x\\\", \\\"value\\\": 0}, \\\"y\\\": {\\\"scale\\\": \\\"y\\\", \\\"field\\\": \\\"label\\\"}, \\\"height\\\": {\\\"scale\\\": \\\"y\\\", \\\"band\\\": true}, \\\"fill\\\": {\\\"value\\\": \\\"#108EE9\\\"}}}}], \\\"scales\\\": [{\\\"name\\\": \\\"x\\\", \\\"type\\\": \\\"linear\\\", \\\"domain\\\": {\\\"data\\\": \\\"data_0\\\", \\\"field\\\": \\\"count\\\"}, \\\"range\\\": [0, {\\\"signal\\\": \\\"width\\\"}], \\\"nice\\\": true, \\\"zero\\\": true}, {\\\"name\\\": \\\"y\\\", \\\"type\\\": \\\"band\\\", \\\"domain\\\": {\\\"data\\\": \\\"data_0\\\", \\\"field\\\": \\\"label\\\", \\\"sort\\\": {\\\"op\\\": \\\"mean\\\", \\\"field\\\": \\\"label_idx\\\", \\\"order\\\": \\\"descending\\\"}}, \\\"range\\\": [{\\\"signal\\\": \\\"height\\\"}, 0], \\\"paddingInner\\\": 0.1, \\\"paddingOuter\\\": 0.05}], \\\"axes\\\": [{\\\"orient\\\": \\\"top\\\", \\\"scale\\\": \\\"x\\\", \\\"labelOverlap\\\": true, \\\"tickCount\\\": {\\\"signal\\\": \\\"ceil(width/40)\\\"}, \\\"title\\\": \\\"Count\\\", \\\"zindex\\\": 1}, {\\\"orient\\\": \\\"top\\\", \\\"scale\\\": \\\"x\\\", \\\"domain\\\": false, \\\"grid\\\": true, \\\"labels\\\": false, \\\"maxExtent\\\": 0, \\\"minExtent\\\": 0, \\\"tickCount\\\": {\\\"signal\\\": \\\"ceil(width/40)\\\"}, \\\"ticks\\\": false, \\\"zindex\\\": 0, \\\"gridScale\\\": \\\"y\\\"}, {\\\"scale\\\": \\\"y\\\", \\\"labelOverlap\\\": true, \\\"orient\\\": \\\"left\\\", \\\"title\\\": \\\"Values\\\", \\\"zindex\\\": 1}], \\\"config\\\": {\\\"axis\\\": {\\\"gridColor\\\": \\\"rgba(204,204,204,1.0)\\\", \\\"labelFont\\\": \\\"\\\\\\\"San Francisco\\\\\\\", HelveticaNeue, Arial\\\", \\\"labelFontSize\\\": 12, \\\"labelPadding\\\": 10, \\\"labelColor\\\": \\\"rgba(0,0,0,0.847)\\\", \\\"tickColor\\\": \\\"rgb(136,136,136)\\\", \\\"titleFont\\\": \\\"\\\\\\\"San Francisco\\\\\\\", HelveticaNeue, Arial\\\", \\\"titleFontWeight\\\": \\\"normal\\\", \\\"titlePadding\\\": 20, \\\"titleFontSize\\\": 14, \\\"titleColor\\\": \\\"rgba(0,0,0,0.847)\\\"}, \\\"axisY\\\": {\\\"minExtent\\\": 30}, \\\"legend\\\": {\\\"labelFont\\\": \\\"\\\\\\\"San Francisco\\\\\\\", HelveticaNeue, Arial\\\", \\\"labelColor\\\": \\\"rgba(0,0,0,0.847)\\\", \\\"titleFont\\\": \\\"\\\\\\\"San Francisco\\\\\\\", HelveticaNeue, Arial\\\", \\\"cornerRadius\\\": 30, \\\"gradientLength\\\": 608, \\\"titleColor\\\": \\\"rgba(0,0,0,0.847)\\\"}, \\\"range\\\": {\\\"heatmap\\\": {\\\"scheme\\\": \\\"greenblue\\\"}}, \\\"style\\\": {\\\"rect\\\": {\\\"stroke\\\": \\\"rgba(200, 200, 200, 0.5)\\\"}, \\\"cell\\\": {\\\"stroke\\\": \\\"transparent\\\"}, \\\"group-title\\\": {\\\"fontSize\\\": 29, \\\"font\\\": \\\"HelveticaNeue, Arial\\\", \\\"fontWeight\\\": \\\"normal\\\", \\\"fill\\\": \\\"rgba(0,0,0,0.65)\\\"}}, \\\"title\\\": {\\\"color\\\": \\\"rgba(0,0,0,0.847)\\\", \\\"font\\\": \\\"\\\\\\\"San Francisco\\\\\\\", HelveticaNeue, Arial\\\", \\\"fontSize\\\": 18, \\\"fontWeight\\\": \\\"normal\\\", \\\"offset\\\": 30}}}\";                                 var vega_json_parsed = JSON.parse(vega_json);                                 var toolTipOpts = {                                     showAllFields: true                                 };                                 if(vega_json_parsed[\"metadata\"] != null){                                     if(vega_json_parsed[\"metadata\"][\"bubbleOpts\"] != null){                                         toolTipOpts = vega_json_parsed[\"metadata\"][\"bubbleOpts\"];                                     };                                 };                                 vegaEmbed(\"#vis\", vega_json_parsed).then(function (result) {                                     vegaTooltip.vega(result.view, toolTipOpts);                                  });                             </script>                         </body>                     </html>' src=\"demo_iframe_srcdoc.htm\">                         <p>Your browser does not support iframes.</p>                     </iframe>                 </body>             </html>"
            ],
            "text/plain": [
              "<IPython.core.display.HTML object>"
            ]
          },
          "metadata": {
            "tags": []
          }
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "GApIFF7Rf0fm",
        "outputId": "fa1cc8f4-92ca-4b4e-d52b-dac0711287df"
      },
      "source": [
        "# Class/Target & Features\n",
        "df.column_names()\n"
      ],
      "execution_count": 19,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "['Age',\n",
              " 'Gender',\n",
              " 'Polyuria',\n",
              " 'Polydipsia',\n",
              " 'sudden weight loss',\n",
              " 'weakness',\n",
              " 'Polyphagia',\n",
              " 'Genital thrush',\n",
              " 'visual blurring',\n",
              " 'Itching',\n",
              " 'Irritability',\n",
              " 'delayed healing',\n",
              " 'partial paresis',\n",
              " 'muscle stiffness',\n",
              " 'Alopecia',\n",
              " 'Obesity',\n",
              " 'class']"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 19
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "UyrSY7GRf0rB"
      },
      "source": [
        "feature_names = ['Age',\n",
        " 'Gender',\n",
        " 'Polyuria',\n",
        " 'Polydipsia',\n",
        " 'sudden weight loss',\n",
        " 'weakness',\n",
        " 'Polyphagia',\n",
        " 'Genital thrush',\n",
        " 'visual blurring',\n",
        " 'Itching',\n",
        " 'Irritability',\n",
        " 'delayed healing',\n",
        " 'partial paresis',\n",
        " 'muscle stiffness',\n",
        " 'Alopecia',\n",
        " 'Obesity']"
      ],
      "execution_count": 20,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "Mn0c2QANgDOH"
      },
      "source": [
        "#### Split Dataset\n",
        "train_data,test_data = df.random_split(0.7)"
      ],
      "execution_count": 21,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "X7s03OodgMO2",
        "outputId": "9b040bcd-a727-4361-c37e-e1527ce94d0c"
      },
      "source": [
        "# Training\n",
        "train_data.shape"
      ],
      "execution_count": 22,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "(367, 17)"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 22
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "ShBvLSMygOZt",
        "outputId": "77457cf1-7e2e-4530-c026-987eded3268b"
      },
      "source": [
        "# Original Shape\n",
        "df.shape\n"
      ],
      "execution_count": 23,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "(520, 17)"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 23
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 417
        },
        "id": "Zrkr_UDdgPxB",
        "outputId": "86216e86-1c18-492d-889a-2067c553970b"
      },
      "source": [
        "# Build Model\n",
        "lr_model = tc.logistic_classifier.create(train_data,target='class',features=feature_names)"
      ],
      "execution_count": 25,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "PROGRESS: Creating a validation set from 5 percent of training data. This may take a while.\n",
            "          You can set ``validation_set=None`` to disable validation tracking.\n",
            "\n"
          ],
          "name": "stdout"
        },
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "<pre>Logistic regression:</pre>"
            ],
            "text/plain": [
              "Logistic regression:"
            ]
          },
          "metadata": {
            "tags": []
          }
        },
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "<pre>--------------------------------------------------------</pre>"
            ],
            "text/plain": [
              "--------------------------------------------------------"
            ]
          },
          "metadata": {
            "tags": []
          }
        },
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "<pre>Number of examples          : 348</pre>"
            ],
            "text/plain": [
              "Number of examples          : 348"
            ]
          },
          "metadata": {
            "tags": []
          }
        },
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "<pre>Number of classes           : 2</pre>"
            ],
            "text/plain": [
              "Number of classes           : 2"
            ]
          },
          "metadata": {
            "tags": []
          }
        },
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "<pre>Number of feature columns   : 16</pre>"
            ],
            "text/plain": [
              "Number of feature columns   : 16"
            ]
          },
          "metadata": {
            "tags": []
          }
        },
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "<pre>Number of unpacked features : 16</pre>"
            ],
            "text/plain": [
              "Number of unpacked features : 16"
            ]
          },
          "metadata": {
            "tags": []
          }
        },
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "<pre>Number of coefficients      : 17</pre>"
            ],
            "text/plain": [
              "Number of coefficients      : 17"
            ]
          },
          "metadata": {
            "tags": []
          }
        },
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "<pre>Starting Newton Method</pre>"
            ],
            "text/plain": [
              "Starting Newton Method"
            ]
          },
          "metadata": {
            "tags": []
          }
        },
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "<pre>--------------------------------------------------------</pre>"
            ],
            "text/plain": [
              "--------------------------------------------------------"
            ]
          },
          "metadata": {
            "tags": []
          }
        },
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "<pre>+-----------+----------+--------------+-------------------+---------------------+</pre>"
            ],
            "text/plain": [
              "+-----------+----------+--------------+-------------------+---------------------+"
            ]
          },
          "metadata": {
            "tags": []
          }
        },
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "<pre>| Iteration | Passes   | Elapsed Time | Training Accuracy | Validation Accuracy |</pre>"
            ],
            "text/plain": [
              "| Iteration | Passes   | Elapsed Time | Training Accuracy | Validation Accuracy |"
            ]
          },
          "metadata": {
            "tags": []
          }
        },
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "<pre>+-----------+----------+--------------+-------------------+---------------------+</pre>"
            ],
            "text/plain": [
              "+-----------+----------+--------------+-------------------+---------------------+"
            ]
          },
          "metadata": {
            "tags": []
          }
        },
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "<pre>| 1         | 2        | 0.013721     | 0.931034          | 0.894737            |</pre>"
            ],
            "text/plain": [
              "| 1         | 2        | 0.013721     | 0.931034          | 0.894737            |"
            ]
          },
          "metadata": {
            "tags": []
          }
        },
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "<pre>| 2         | 3        | 0.015912     | 0.951149          | 0.842105            |</pre>"
            ],
            "text/plain": [
              "| 2         | 3        | 0.015912     | 0.951149          | 0.842105            |"
            ]
          },
          "metadata": {
            "tags": []
          }
        },
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "<pre>| 3         | 4        | 0.017795     | 0.956897          | 0.842105            |</pre>"
            ],
            "text/plain": [
              "| 3         | 4        | 0.017795     | 0.956897          | 0.842105            |"
            ]
          },
          "metadata": {
            "tags": []
          }
        },
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "<pre>| 4         | 5        | 0.021800     | 0.968391          | 0.842105            |</pre>"
            ],
            "text/plain": [
              "| 4         | 5        | 0.021800     | 0.968391          | 0.842105            |"
            ]
          },
          "metadata": {
            "tags": []
          }
        },
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "<pre>| 5         | 6        | 0.025123     | 0.965517          | 0.842105            |</pre>"
            ],
            "text/plain": [
              "| 5         | 6        | 0.025123     | 0.965517          | 0.842105            |"
            ]
          },
          "metadata": {
            "tags": []
          }
        },
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "<pre>| 7         | 8        | 0.027796     | 0.965517          | 0.842105            |</pre>"
            ],
            "text/plain": [
              "| 7         | 8        | 0.027796     | 0.965517          | 0.842105            |"
            ]
          },
          "metadata": {
            "tags": []
          }
        },
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "<pre>+-----------+----------+--------------+-------------------+---------------------+</pre>"
            ],
            "text/plain": [
              "+-----------+----------+--------------+-------------------+---------------------+"
            ]
          },
          "metadata": {
            "tags": []
          }
        },
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "<pre>SUCCESS: Optimal solution found.</pre>"
            ],
            "text/plain": [
              "SUCCESS: Optimal solution found."
            ]
          },
          "metadata": {
            "tags": []
          }
        },
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "<pre></pre>"
            ],
            "text/plain": [
              ""
            ]
          },
          "metadata": {
            "tags": []
          }
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "gYRe1OCtgz0U",
        "outputId": "3c172b11-689a-4f8d-c8c1-e1387cfd64aa"
      },
      "source": [
        "# Get model summary\n",
        "lr_model.summary()"
      ],
      "execution_count": 27,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "Class                          : LogisticClassifier\n",
            "\n",
            "Schema\n",
            "------\n",
            "Number of coefficients         : 17\n",
            "Number of examples             : 348\n",
            "Number of classes              : 2\n",
            "Number of feature columns      : 16\n",
            "Number of unpacked features    : 16\n",
            "\n",
            "Hyperparameters\n",
            "---------------\n",
            "L1 penalty                     : 0.0\n",
            "L2 penalty                     : 0.01\n",
            "\n",
            "Training Summary\n",
            "----------------\n",
            "Solver                         : newton\n",
            "Solver iterations              : 7\n",
            "Solver status                  : SUCCESS: Optimal solution found.\n",
            "Training time (sec)            : 0.0333\n",
            "\n",
            "Settings\n",
            "--------\n",
            "Log-likelihood                 : 42.9568\n",
            "\n",
            "Highest Positive Coefficients\n",
            "-----------------------------\n",
            "Gender[Female]                 : 5.1663\n",
            "Irritability[Yes]              : 3.5232\n",
            "Itching[No]                    : 3.4068\n",
            "Polyuria[Yes]                  : 3.2939\n",
            "Genital thrush[Yes]            : 2.4532\n",
            "\n",
            "Lowest Negative Coefficients\n",
            "----------------------------\n",
            "Polydipsia[No]                 : -6.5078\n",
            "Alopecia[No]                   : -0.8826\n",
            "weakness[No]                   : -0.283\n",
            "Age                            : -0.0729\n",
            "\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "zQoSaGxMgk-N"
      },
      "source": [
        "### Model Evaluation\n",
        "metrics = lr_model.evaluate(test_data)"
      ],
      "execution_count": 28,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "aLTOwe9ihACi",
        "outputId": "d514b57d-9891-48e8-f7f7-3df522c997d5"
      },
      "source": [
        "metrics"
      ],
      "execution_count": 29,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "{'accuracy': 0.9084967320261438,\n",
              " 'auc': 0.9548611111111112,\n",
              " 'confusion_matrix': Columns:\n",
              " \ttarget_label\tstr\n",
              " \tpredicted_label\tstr\n",
              " \tcount\tint\n",
              " \n",
              " Rows: 4\n",
              " \n",
              " Data:\n",
              " +--------------+-----------------+-------+\n",
              " | target_label | predicted_label | count |\n",
              " +--------------+-----------------+-------+\n",
              " |   Negative   |     Negative    |   51  |\n",
              " |   Negative   |     Positive    |   6   |\n",
              " |   Positive   |     Positive    |   88  |\n",
              " |   Positive   |     Negative    |   8   |\n",
              " +--------------+-----------------+-------+\n",
              " [4 rows x 3 columns],\n",
              " 'f1_score': 0.9263157894736843,\n",
              " 'log_loss': 0.29441990146756725,\n",
              " 'precision': 0.9361702127659575,\n",
              " 'recall': 0.9166666666666666,\n",
              " 'roc_curve': Columns:\n",
              " \tthreshold\tfloat\n",
              " \tfpr\tfloat\n",
              " \ttpr\tfloat\n",
              " \tp\tint\n",
              " \tn\tint\n",
              " \n",
              " Rows: 1001\n",
              " \n",
              " Data:\n",
              " +-----------+--------------------+-----+----+----+\n",
              " | threshold |        fpr         | tpr | p  | n  |\n",
              " +-----------+--------------------+-----+----+----+\n",
              " |    0.0    |        1.0         | 1.0 | 96 | 57 |\n",
              " |   0.001   | 0.9122807017543859 | 1.0 | 96 | 57 |\n",
              " |   0.002   | 0.8596491228070176 | 1.0 | 96 | 57 |\n",
              " |   0.003   | 0.8596491228070176 | 1.0 | 96 | 57 |\n",
              " |   0.004   | 0.8596491228070176 | 1.0 | 96 | 57 |\n",
              " |   0.005   | 0.8596491228070176 | 1.0 | 96 | 57 |\n",
              " |   0.006   | 0.8421052631578947 | 1.0 | 96 | 57 |\n",
              " |   0.007   | 0.8421052631578947 | 1.0 | 96 | 57 |\n",
              " |   0.008   | 0.8245614035087719 | 1.0 | 96 | 57 |\n",
              " |   0.009   | 0.8245614035087719 | 1.0 | 96 | 57 |\n",
              " +-----------+--------------------+-----+----+----+\n",
              " [1001 rows x 5 columns]\n",
              " Note: Only the head of the SFrame is printed.\n",
              " You can use print_rows(num_rows=m, num_columns=n) to print more rows and columns.}"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 29
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "m_lUpPqlhBGe",
        "outputId": "fb8cc134-65c6-4fe9-fea1-2a2c0ee9941a"
      },
      "source": [
        "type(metrics)"
      ],
      "execution_count": 30,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "dict"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 30
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "BKXK5gvphJFr",
        "outputId": "06f5a6d9-c4ac-43a8-8619-978c9366ade1"
      },
      "source": [
        "# Get Accuracy\n",
        "metrics['accuracy']"
      ],
      "execution_count": 31,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "0.9084967320261438"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 31
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "6Exg_EIVhXK8"
      },
      "source": [
        "#### Rules for Making Single Sample Prediction\n",
        "+ Must be an SFrame"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "kaJXEYZWi5eg"
      },
      "source": [
        "d = {'Age': 41,\n",
        " 'Alopecia': 'Yes',\n",
        " 'Gender': 'Male',\n",
        " 'Genital thrush': 'No',\n",
        " 'Irritability': 'No',\n",
        " 'Itching': 'Yes',\n",
        " 'Obesity': 'No',\n",
        " 'Polydipsia': 'No',\n",
        " 'Polyphagia': 'Yes',\n",
        " 'Polyuria': 'Yes',\n",
        " 'class': 'Positive',\n",
        " 'delayed healing': 'Yes',\n",
        " 'muscle stiffness': 'Yes',\n",
        " 'partial paresis': 'No',\n",
        " 'sudden weight loss': 'No',\n",
        " 'visual blurring': 'No',\n",
        " 'weakness': 'Yes'}\n"
      ],
      "execution_count": 52,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "lXaIDdYvheS7"
      },
      "source": [
        "ex1 = tc.SFrame({'data':[d.values()]})"
      ],
      "execution_count": 53,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 92
        },
        "id": "8XI_ocS6iKLV",
        "outputId": "8be0f04e-746e-413c-d77a-2844bedac72a"
      },
      "source": [
        "ex1"
      ],
      "execution_count": 54,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/html": [
              "<div style=\"max-height:1000px;max-width:1500px;overflow:auto;\"><table frame=\"box\" rules=\"cols\">\n",
              "    <tr>\n",
              "        <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">data</th>\n",
              "    </tr>\n",
              "    <tr>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">[41, Yes, Male, No, No,<br>Yes, No, No, Yes, Yes, ...</td>\n",
              "    </tr>\n",
              "</table>\n",
              "[1 rows x 1 columns]<br/>\n",
              "</div>"
            ],
            "text/plain": [
              "Columns:\n",
              "\tdata\tlist\n",
              "\n",
              "Rows: 1\n",
              "\n",
              "Data:\n",
              "+-------------------------------+\n",
              "|              data             |\n",
              "+-------------------------------+\n",
              "| [41, Yes, Male, No, No, Ye... |\n",
              "+-------------------------------+\n",
              "[1 rows x 1 columns]"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 54
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "dPA76OYIhOFJ",
        "outputId": "88e8a5d1-25a9-46fd-98d2-a896f6db012c"
      },
      "source": [
        "# Make Prediction\n",
        "lr_model.predict(ex1)"
      ],
      "execution_count": 55,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "dtype: str\n",
              "Rows: 1\n",
              "['Negative']"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 55
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 75
        },
        "id": "IuMW5TX5hvYo",
        "outputId": "8eb10ba3-740d-4457-e93a-4579b9d9cbbb"
      },
      "source": [
        "# Prediction Prob\n",
        "lr_model.classify(ex1)"
      ],
      "execution_count": 56,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/html": [
              "<div style=\"max-height:1000px;max-width:1500px;overflow:auto;\"><table frame=\"box\" rules=\"cols\">\n",
              "    <tr>\n",
              "        <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">class</th>\n",
              "        <th style=\"padding-left: 1em; padding-right: 1em; text-align: center\">probability</th>\n",
              "    </tr>\n",
              "    <tr>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">Negative</td>\n",
              "        <td style=\"padding-left: 1em; padding-right: 1em; text-align: center; vertical-align: top\">0.9191211571241118</td>\n",
              "    </tr>\n",
              "</table>\n",
              "[1 rows x 2 columns]<br/>\n",
              "</div>"
            ],
            "text/plain": [
              "Columns:\n",
              "\tclass\tstr\n",
              "\tprobability\tfloat\n",
              "\n",
              "Rows: 1\n",
              "\n",
              "Data:\n",
              "+----------+--------------------+\n",
              "|  class   |    probability     |\n",
              "+----------+--------------------+\n",
              "| Negative | 0.9191211571241118 |\n",
              "+----------+--------------------+\n",
              "[1 rows x 2 columns]"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 56
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "0A2XyN8bjmRh"
      },
      "source": [
        "# Save Model\n",
        "lr_model.save('dm_risk_lr_classifier_27_may_2021.model')"
      ],
      "execution_count": 57,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "JcUSDXHPjzD-"
      },
      "source": [
        "### Thanks For Watching\n",
        "### Jesus Saves @JCharisTech\n",
        "### Jesse E.Agbe(JCharis)"
      ],
      "execution_count": null,
      "outputs": []
    }
  ]
}